00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _app_environment_hpp_
00022 #define _app_environment_hpp_
00023
00024 #include <boost/mpi.hpp>
00025 #include "gridpack/utilities/uncopyable.hpp"
00026
00027
00028 namespace gridpack {
00029
00030 class CommandLineParser {
00031 public:
00032 CommandLineParser (int &argc, char **argv)
00033 {
00034 for (int i=1; i < argc; ++i) this->tokens.push_back(std::string(argv[i]));
00035 }
00036
00037 const std::string& getCmdOption(const std::string &option) const
00038 {
00039 std::vector<std::string>::const_iterator itr;
00040 itr = std::find(this->tokens.begin(), this->tokens.end(), option);
00041 if (itr != this->tokens.end() && ++itr != this->tokens.end()){
00042 return *itr;
00043 }
00044 static const std::string empty_string("");
00045 return empty_string;
00046 }
00047
00048 bool cmdOptionExists(const std::string &option) const{
00049 return std::find(this->tokens.begin(), this->tokens.end(), option)
00050 != this->tokens.end();
00051 }
00052 private:
00053 std::vector <std::string> tokens;
00054 };
00055
00056
00057
00058
00059 class Environment : private utility::Uncopyable
00060 {
00061 public:
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 Environment(int argc, char **argv,
00074 const char* help);
00075
00076 Environment(int argc, char **argv,
00077 const char* help,
00078 const long int& ma_stack,
00079 const long int& ma_heap);
00080
00081 Environment(int argc, char **argv);
00082
00083
00084
00085 ~Environment(void);
00086
00087 protected:
00088 boost::mpi::environment p_boostEnv;
00089
00090 private:
00091
00092 CommandLineParser clparser;
00093
00094
00095 long int pma_stack;
00096 long int pma_heap;
00097
00098 void PrintHelp(char **argv,const char* help);
00099 };
00100
00101 }
00102
00103 #endif